Repository navigation
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The sample
hooks/pre-commitnever rejected anything on macOS. The character class[0-9A-Za-z\-_]is an invalid range for the BSDgrepshipped with macOS, sogrepfails withinvalid character range, exits with 2, and the hook takes it as "no match" and lets the commit through. GNUgrepaccepts it, which is probably why it went unnoticed. The same hook has been copied to other repos (i.e. android-maps-compose), so they inherit the issue.Changes:
[0-9A-Za-z_-]{35}, which is portable between BSD and GNUgrep.git diff --cached) instead of the working copy, so it looks at what is actually going to be committed.local.defaults.properties, since a key pasted in a Kotlin file or a README is the more realistic leak. Only added lines are checked, so a commit that removes a key still goes through.Testing
Tested in a scratch repo with
/usr/bin/grepon macOS:MAPS_API_KEY=YOUR_API_KEY: committed..propertiesfile: rejected..ktfile: rejected.